<?php
if ( !defined( "IN_OP" ) )
{
    exit( "You can't access this file directly..." );
}
if ( $curruser['acl'] != 255 || $curruser['account'] != G_SUPERACCOUNT )
{
    exit();
}
$gametype = intval( getvar( "gametype" ) );
$gType = $gametype;
$chkGametype = chkGametype( $gametype );
if ( $chkGametype )
{
    include_once( "class_3d/CheckMode_3d.php" );
    $chk = new CheckMode_3d( $curruser['acl'], 1, $gametype );
    $chk->checkShow3dPage();
    $show3D3S = $chk->show3D3S;
    unset( $chk );
    $ui = new UI_3D( true, "报表管理" );
    $jslink = "<script language=\"JScript.Encode\" src=\"site.js\"></script>".( "<script language=\"VBScript.Encode\" src=\"site.vbs\"></script>" );
    $ui->set( "jslink", $jslink );
    $ui->header();
    include( "admin_menu_3d.php" );
}
else
{
    $ui = new UI( true, "报表管理" );
    include( "admin_menu.php" );
}
include_once( "class/function_3d.php" );
$tpl = new Template2();
$conf = new Config();
$init_start_modeOld = $conf->Get( "init_start_mode" );
$member_limit = intval( $conf->Get( "member_limit" ) );
$paper_show_pn = intval( $conf->Get( "paper_show_pn" ) );
$paper_post_bet = $conf->Get( "paper_post_bet" );
$systemcheck = intval( $conf->Get( "systemcheck" ) );
$paper_from_dateOld = $conf->Get( "paper_from_date" );
$paper_from_date = $paper_from_dateOld;
$floatBack3s = intval( $conf->Get( "floatBack_3s" ) );
$_5hxyMode = intval( $conf->Get( "5hxyMode" ) );
$_5hx21Mode = intval( $conf->Get( "5hx21Mode" ) );
$_5hy21Mode = intval( $conf->Get( "5hy21Mode" ) );
$paper_master_enabled = intval( $conf->Get( "paper_master_enabled" ) );
$page_max_count = intval( $conf->Get( "page_max_count" ) );
$page_max_count_ag = intval( $conf->Get( "page_max_count_ag" ) );
$domain_list = $conf->Get( "domain_list" );
$chkUpKuserChk = "";
$upFlag = false;
$nameArr = array( 1 => "全部", 2 => "六合彩", 3 => "快开彩" );
$weekallname = array( "日", "一", "二", "三", "四", "五", "六" );
$msg = "";
if ( ispost( ) )
{
    $member_len = intval( getvar( "member_len" ) );
    if ( $member_len != $member_limit )
    {
        $conf->set( "member_limit", $member_len );
        $member_limit = $member_len;
        $msg .= "<div class=green>本系统使用人数 更新成功</div>";
    }
    $chkUpKuser = intval( getvar( "chkUpKuser" ) );
    $init_start_mode = intval( getvar( "initMode" ) );
    if ( $init_start_mode != $init_start_modeOld && 0 < $init_start_mode )
    {
        $conf->set( "init_start_mode", $init_start_mode );
        $msgTemp = "";
        if ( 1 < $init_start_mode && 0 < $chkUpKuser )
        {
            $sql = "update k_user set init_start_mode = {$init_start_mode} where 1";
            getdb( $sql );
            $msgTemp = "使用者资料表同步成功！";
            $chkUpKuserChk = "checked";
        }
        $msg = "<script language=\"JavaScript\">\r\n    function chgURl(){\r\n      window.top.location.href = 'op.php?op=core&fp=logout';\r\n    }\r\n    setTimeout(function(){chgURl();},4000);\r\n    alert('修改类别成功！{$msgTemp}请动新登入 (4秒後将自动登出！)');\r\n    </script>";
        $upFlag = true;
        $init_start_modeOld = $init_start_mode;
    }
    else if ( 0 < $chkUpKuser && 1 < $init_start_modeOld )
    {
        $sql = "update k_user set init_start_mode = {$init_start_modeOld} where 1";
        getdb( $sql );
        $msg .= "<div class=green>已将使用者可用彩类同步为「{$nameArr[$init_start_modeOld]}」</div>";
        $chkUpKuserChk = "checked";
    }
    $new_paper_post_bet = intval( getvar( "paper_post_bet" ) );
    if ( $new_paper_post_bet != intval( $paper_post_bet ) )
    {
        $msgPostBet = "";
        if ( 4 < strlen( $new_paper_post_bet ) )
        {
            $msgPostBet .= "<div class=red>注单过帐时间 格式错误, 更新系统注单过帐时间失败</div>";
        }
        else
        {
            $new_paper_post_bet = str_pad( $new_paper_post_bet, 4, "0", STR_PAD_LEFT );
        }
        $hTemp = intval( substr( $new_paper_post_bet, 0, 2 ) );
        $mTemp = intval( substr( $new_paper_post_bet, 2, 2 ) );
        if ( 23 < $hTemp || $hTemp < 0 )
        {
            $msgPostBet .= "<div class=red>注单过帐时间 小时格式错误, 更新系统注单过帐时间失败</div>";
        }
        else if ( 59 < $mTemp || $mTemp < 0 )
        {
            $msgPostBet .= "<div class=red>注单过帐时间 分钟格式错误, 更新系统注单过帐时间失败</div>";
        }
        if ( $msgPostBet == "" )
        {
            $conf->set( "paper_post_bet", $new_paper_post_bet );
            $paper_post_bet = $new_paper_post_bet;
            $msg .= "<div class=green>注单过帐时间 更新成功</div>";
        }
        else
        {
            $msg .= $msgPostBet;
        }
    }
    $new_paper_show_pn = intval( getvar( "paper_show_pn" ) );
    if ( $new_paper_show_pn != $paper_show_pn )
    {
        $conf->set( "paper_show_pn", $new_paper_show_pn );
        $msg .= "<div class=green>系统公司报表第一页显示设定 更新成功</div>";
        $paper_show_pn = $new_paper_show_pn;
    }
    $new_paper_from_date = getvar( "paper_from_date" );
    $new_paper_from_date = is_date( $new_paper_from_date, 1 );
    if ( $new_paper_from_date && $new_paper_from_date != $paper_from_dateOld )
    {
        $conf->set( "paper_from_date", $new_paper_from_date );
        $msg .= "<div class=green>可看最小报表日 更新成功</div>";
        $paper_from_date = $new_paper_from_date;
    }
    $new_systemcheck = intval( getvar( "systemcheck" ) );
    if ( $new_systemcheck != $systemcheck )
    {
        $conf->set( "systemcheck", $new_systemcheck );
        $msg .= "<div class=green>全博奕系统维护中 更新成功</div>";
        $systemcheck = $new_systemcheck;
    }
    $new_floatBack3s = intval( getvar( "floatBack3s" ) );
    if ( $new_floatBack3s != $floatBack3s )
    {
        $conf->set( "floatBack_3s", $new_floatBack3s );
        $msg .= "<div class=green>时时彩会员下注退水使用设定 更新成功</div>";
        $floatBack3s = $new_floatBack3s;
    }
    $_5hxyMode_new = intval( getvar( "_5hxyMode" ) );
    if ( $_5hxyMode_new != $_5hxyMode )
    {
        $conf->set( "5hxyMode", $_5hxyMode_new );
        $_5hxyMode = $_5hxyMode_new;
        $msg .= "<div class=green>广西彩快乐十分XY盘类开放设定 更新成功</div>";
    }
    $_5hx21Mode_new = intval( getvar( "_5hx21Mode" ) );
    if ( $_5hx21Mode_new != $_5hx21Mode )
    {
        $conf->set( "5hx21Mode", $_5hx21Mode_new );
        $_5hx21Mode = $_5hx21Mode_new;
        $msg .= "<div class=green>广西彩快乐十分X盘21和输设定 更新成功</div>";
    }
    $_5hy21Mode_new = intval( getvar( "_5hy21Mode" ) );
    if ( $_5hy21Mode_new != $_5hy21Mode )
    {
        $conf->set( "5hy21Mode", $_5hy21Mode_new );
        $_5hy21Mode = $_5hy21Mode_new;
        $msg .= "<div class=green>广西彩快乐十分Y盘21和输设定 更新成功</div>";
    }
    $new_paper_master_enabled = intval( getvar( "paper_master_enabled" ) );
    if ( $new_paper_master_enabled != $paper_master_enabled )
    {
        $conf->set( "paper_master_enabled", $new_paper_master_enabled );
        $msg .= "<div class=green>特别帐号不受限 更新成功</div>";
        $paper_master_enabled = $new_paper_master_enabled;
    }
    $new_domain_list = getvar( "domain_list" );
    if ( $new_domain_list != $domain_list )
    {
        $conf->set( "domain_list", $new_domain_list );
        $msg .= "<div class=green>允许\登入网址清单 更新成功</div>";
        $domain_list = $new_domain_list;
    }
}
$title = isset( $nameArr[$init_start_modeOld] ) ? $nameArr[$init_start_modeOld] : " -尚未设定- ";
$ui->load( "calendar_js", "calendar_js.htm" );
$ui->show( "calendar_js" );
echo title( "本站玩法设定 :: 目前的设定 :: 【{$title}】" );
echo "<center>{$msg}</center>";
echo "<style> .myc2{background-color:#e7ebef;text-align:right;} </style>";
echo "<form action=\"op.php?op=admin&fp=setInitMode\" method=\"post\">";
echo "<input type=hidden name=gametype value={$gametype} />";
echo "<table class=table0 border=0 cellpadding=3 cellspacing=1 width='100%' >";
echo "<thead class='bgClc_{$gametype}' style='font-size:14px;text-align:center'><tr><th>项目</th><th>选项</th><th>备注</th></tr></thead>";
echo "<tr class=td2><td class='myc2'>版本</td><td colspan=2>".$conf->get( "version" )."</td></tr>";
echo "<tr class=td2><td class='myc2' rowspan=3 >请选择开放类别:</td>";
$i = 0;
foreach ( $nameArr as $key => $val )
{
    $chkStr = $key == $init_start_modeOld ? " checked " : "";
    echo "<td><label><input name=\"initMode\" type=\"radio\" value=\"{$key}\" {$chkStr} />&nbsp;{$val}</label></td>";
    if ( $i < 1 )
    {
        echo "<td rowspan=3 ><label style='color:red;'><input type='checkbox' value='1' name='chkUpKuser' {$chkUpKuserChk} />同步使用者资料表之博奕类别设定值</label><hr /><ul style='margin-top:0'>勾选时, <li>开放类别异动为<font color=red> [六合彩] </font>或 <font color=red>[快开彩]</font> 时,<br />将<strong>同步使用者资料表之博奕类别设定</strong>。</li><li>异动为<font color=red>[全部]</font>时,<br /><strong>保留原使用者之博奕类别设定</strong>。</li></ul></td>";
    }
    echo "</tr>";
    echo "<tr class=td2 valign=top >";
    ++$i;
}
echo "<td class='myc2'>本系统使用人数:</td><td><input size=6 name=member_len value=\"{$member_limit}\" type='text'></td><td>&nbsp;</td></tr>";
if ( $domain_list )
{
    echo "<tr class=td2><td class='myc2'>允许\登入网址清单:</td><td><input size=40 name=domain_list value=\"{$domain_list}\" type='text'></td><td>请以逗号间隔,空白代表不限制&nbsp;</td></tr>";
}
if ( $paper_show_pn )
{
    $paper_show_pn_CHK0 = "";
    $paper_show_pn_CHK1 = " checked";
}
else
{
    $paper_show_pn_CHK0 = " checked";
    $paper_show_pn_CHK1 = "";
}
if ( $systemcheck )
{
    $systemcheck_CHK0 = "";
    $systemcheck_CHK1 = " checked";
}
else
{
    $systemcheck_CHK0 = " checked";
    $systemcheck_CHK1 = "";
}
if ( $floatBack3s )
{
    $floatBack3s_CHK0 = "";
    $floatBack3s_CHK1 = " checked";
}
else
{
    $floatBack3s_CHK0 = " checked";
    $floatBack3s_CHK1 = "";
}
$chk5hxyMode0 = $_5hxyMode == 0 ? "checked" : "";
$chk5hxyMode1 = $_5hxyMode == 1 ? "checked" : "";
$chk5hx21Mode0 = $_5hx21Mode == 0 ? "checked" : "";
$chk5hx21Mode1 = $_5hx21Mode == 0 - 1 ? "checked" : "";
$chk5hy21Mode0 = $_5hy21Mode == 0 ? "checked" : "";
$chk5hy21Mode1 = $_5hy21Mode == 0 - 1 ? "checked" : "";
$paper_master_enabled_CHK = $paper_master_enabled ? " checked" : "";
echo "<tr class=td2><td class='myc2' align=right>公司报表第一页显示设定:</td><td><label><input type='radio' value='0' name='paper_show_pn' {$paper_show_pn_CHK0} />会员负,公司正</label>";
echo "&nbsp;&nbsp;<label><input type='radio' value='1' name='paper_show_pn' ".$paper_show_pn_CHK1." />会员负,公司负</label></td><td>本设定只影响公司报表第一页之数据</td></tr>";
echo "<tr class=td2><td class='myc2' align=right>注单过帐时间(bet -> xbet):</td><td><input type=text size=6 name='paper_post_bet' value=\"{$paper_post_bet}\">&nbsp;&nbsp;(24 小时制 0000 ~ 2359)</td><td>需设定排程(自动颁奖)配合</td></tr>";
echo "<tr class=td2><td class='myc2' align=right>可看最小报表日:</td><td><input type=text name='paper_from_date' value=\"{$paper_from_date}\" id=\"paper_from_date\" size=\"10\"><a href=\"#\" onclick=\"javascript:showCalendarById('paper_from_date')\"><img align=absmiddle src=\"class/calendar/calendar.png\"  alt=\"开启小月历\"  border=0></a>&nbsp;&nbsp;(日期格式 0000-00-00)</td><td>若无设值,预设为当月1日。执行资料表清除时,会自动更新该值</td></tr>";
echo "<tr class=td2><td class='myc2' align=right>目前可看最小报表日:</td><td colspan=2><font color=blue>管理:".getPaperMinDate( 0 - 1 )." </font>, <font color=red>会员:".getPaperMinDate( 0 - 1, 1 )."</font>◎旧帐显示数-管理:".( 10 < $page_max_count_ag ? "全部" : "{$page_max_count_ag}天" )."</font>,会员:".( 10 < $page_max_count ? "全部" : "{$page_max_count}天" )."<br />「可看最小报表日」与「旧帐显示数(管理/会员)」取最大日期值</td></tr>";
echo "<tr class=td2><td class='myc2' align=right>全博奕系统维护中:</td><td><label><input type=radio size=6 name='systemcheck' value=\"1\" {$systemcheck_CHK1}>是</label>&nbsp;&nbsp;<label><input type=radio size=6 name='systemcheck' value=\"0\" {$systemcheck_CHK0}>否</label></td><td>全博奕系统维护中开启时,仅公司阶层之管理者可登入</td></tr>";
//echo "<tr class=td2><td class='myc2' align=right>时时开奖码数:</td><td>".( $g_5number_3d ? "黑龙, 重庆, 江西为「五码」, 其余为「三码」" : "全为「三码」" )."玩法</td><td>&nbsp;</td></tr>";
echo "<tr class=td2><td class='myc2' align=right>会员下注所得退水设定:</td><td><label><input type='radio' value='0' name='floatBack3s' {$floatBack3s_CHK0} /><font color=red>不累加</font>在可用额度</label>";
echo "&nbsp;&nbsp;<label><input type='radio' value='1' name='floatBack3s' ".$floatBack3s_CHK1." /><font color=red>累加</font>在可用额度</label></td><td>设定会员当日下注(时时彩)所得之退水是否累加在「可用额度」</td></tr>";
//echo "<tr class=td2><td class='myc2' rowspan=3 >广西快乐十分设定:</td>";
//echo "<td>开放:&nbsp;&nbsp;<label><input name=\"_5hxyMode\" type=\"radio\" value=\"0\" {$chk5hxyMode0} />&nbsp;X盘</label><input name=\"_5hxyMode\" type=\"radio\" value=\"1\" {$chk5hxyMode1} />&nbsp;X+Y盘</label></td><td>XY盘类开放设定</td>";
//echo "</tr><tr class=td2 valign=top >";
//echo "<td>X盘21:<label><input name=\"_5hx21Mode\" type=\"radio\" value=\"0\" {$chk5hx21Mode0} />&nbsp;和</label><input name=\"_5hx21Mode\" type=\"radio\" value=\"-1\" {$chk5hx21Mode1} />&nbsp;输</label></td><td>X盘21号双面玩法和输设定</td>";
//echo "</tr><tr class=td2 valign=top >";
//echo "<td>Y盘21:<label><input name=\"_5hy21Mode\" type=\"radio\" value=\"0\" {$chk5hy21Mode0} />&nbsp;和</label><input name=\"_5hy21Mode\" type=\"radio\" value=\"-1\" {$chk5hy21Mode1} />&nbsp;输</label></td><td>Y盘21号双面玩法和输设定</td>";
echo "<tr class=td2><td colspan=2 align=right><input type=submit value=确定修改></td><td>&nbsp;</td></tr>";
echo "</table>";
echo "</form>";
$ui->footer();
echo "                 ";
?>